home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / util / batch / ScriptTools.lha / ScriptTools / src / Pathname.mod < prev    next >
Encoding:
Text File  |  1993-12-24  |  1.4 KB  |  75 lines

  1. (*
  2. ** -------------------------------------------------------------------------
  3. ** Program:  Pathname
  4. ** Author:   Keith R. Burby
  5. ** Version:  0.0
  6. ** Date:     23.12.93
  7. ** Description:
  8. ** Extract path name from full path/file name.
  9. ** -------------------------------------------------------------------------
  10. *)
  11.  
  12. (*
  13.   History:
  14.  
  15.   v0.0 (23.12.93)
  16.   First Edition
  17. *)
  18.  
  19. MODULE Pathname;
  20.  
  21.   IMPORT
  22.     (* NoGuru, *)
  23.     s := Strings,
  24.     d := Dos;
  25.  
  26.   CONST
  27.     PrgName = "Pathname\o"
  28.               "$VER: Pathname 0.0 (23.12.93) Keith R. Burby";
  29.  
  30.     DosLibVer = 36;
  31.     ArgTemplate = "NAME/A";
  32.  
  33.   TYPE
  34.     ArgArray = STRUCT (dummy: d.ArgsStruct)
  35.       Name: d.ArgString;
  36.     END;
  37.  
  38.   VAR
  39.     ErrNum: LONGINT;
  40.  
  41.  
  42.   PROCEDURE GetPathname(): LONGINT;
  43.  
  44.     VAR
  45.       MyArgs: ArgArray;
  46.       PathAdr: d.ArgString;
  47.       MyRDArgs: d.RDArgsPtr;
  48.  
  49.     BEGIN
  50.       MyRDArgs := d.ReadArgs(ArgTemplate, MyArgs, NIL);
  51.       IF (MyRDArgs # NIL) THEN
  52.         PathAdr := d.PathPart(MyArgs.Name^);
  53.         PathAdr[0] := "\o";
  54.         d.PrintF("%s\n", MyArgs.Name);
  55.         d.FreeArgs(MyRDArgs);
  56.       END;
  57.       RETURN(d.IoErr());
  58.     END GetPathname;
  59.  
  60.  
  61.   BEGIN
  62.     IF (d.dos.lib.version >= DosLibVer) THEN
  63.       ErrNum := GetPathname();
  64.       IF (ErrNum # 0) THEN
  65.         IF (d.PrintFault(ErrNum, PrgName)) THEN
  66.           HALT(10);
  67.         ELSE
  68.           HALT(20);
  69.         END;
  70.       END;
  71.     ELSE
  72.       HALT(DosLibVer);
  73.     END;
  74.   END Pathname.
  75.